
package com.ukao.pad.presenter;

import android.util.Log;

import com.ukao.pad.base.BasePresenter;
import com.ukao.pad.bean.StationBean;
import com.ukao.pad.bean.StringBean;
import com.ukao.pad.consts.Constant;
import com.ukao.pad.consts.SaveParamets;
import com.ukao.pad.retrofit.ApiCallback;
import com.ukao.pad.utils.T;
import com.ukao.pad.utils.Utils;
import com.ukao.pad.view.HomeView;

import java.util.HashMap;
import java.util.List;

/**
 * Created by ukaodev on 2017/6/28.
 */

public class HomePesenter extends BasePresenter<HomeView> {



    public HomePesenter(HomeView view) {
        attachView(view);
    }


    public void stationTypesRequest() {
        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.stationTypes(Constant.createParameter(mHashMap)),
                new ApiCallback<StationBean>() {
                    @Override
                    public void onSuccess(StationBean model) {
                        if (model.getHttpCode() == 200) {

                            List<StationBean> mAddressList = model.getData();
                            mvpView.loadStationSuccess(mAddressList);


                        } else {
                            T.show(model.getMsg());
                        }
                    }

                    @Override
                    public void onNoNewWork() {

                    }

                    @Override
                    public void onFinish() {

                    }


                });
    }

    public void quitout() {
            mvpView.showLoading();
        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.logout(Constant.createParameter(mHashMap)),
                new ApiCallback<StringBean>() {
                    @Override
                    public void onSuccess(StringBean model) {

                        if (model.getHttpCode() == 200) {

                        } else {
                            T.show(model.getMsg());
                        }
                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                        mvpView.quitoutSuccess();

                    }
                });
    }

 
    }









